/**
 * 用户
 *
 * @author zhu
 * @date 2024-03-12
 */
public class User {
    /**
     * 钥匙的状态
     */
    public String keyStatus;

    public String getKeyStatus() {
        return keyStatus;
    }

    public void setKeyStatus(String keyStatus) {
        this.keyStatus = keyStatus;
    }

    /**
     * 开锁
     * @param door 门对象
     */
    public void unLock(Door door){
        door.lockStatus = "已解锁";
    }

    /**
     * 上锁
     * @param door 门对象
     */
    public void upLock(Door door) {
        door.lockStatus = "已上锁";
    }

    /**
     * 开门
     * @param door 门对象
     */
    public void openDoor(Door door){
        if (keyStatus == "带了钥匙"){
            unLock(door);
            door.openDoor();
        }else if (keyStatus == "没带钥匙"){
            System.out.println(keyStatus + "，开不了门");
        }
    }

    /**
     * 关门
     * @param door 门对象
     */
    public void closeDoor(Door door){
        door.closeDoor();
    }
}
